#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

STAGE_FILES=$(git diff --cached --name-only -- '*.json' '*.js' '*.jsx' '*.ts' '*.tsx' '*.vue')
if test ${#STAGE_FILES} -gt 0
then
    echo '开始代码格式检查与修正'
    for FILE in $STAGE_FILES
    do
        if test -f "$FILE"; then
            echo "$FILE exist 这里是检查的文件名"
            npx prettier --write $FILE
        fi
        if [[ "$?" == 1 ]]; then
      PASS=false
    fi
  done
echo "代码格式化检查完毕"

else
    echo '没有js,jsx,ts,tsx,vue,json文件需要检查'
fi

exit 0

